﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;
using System.IO.IsolatedStorage;
using PoznanEvents.Models;
using Microsoft.Phone.Tasks;
using System.Windows.Markup;
using System.Windows.Navigation;
using System.Text;
using PoznanEvents.Helpers;

namespace PoznanEvents
{
    public partial class EventPage : PhoneApplicationPage
    {
        public EventPage()
        {
            InitializeComponent();
            DataContext = App.ViewModel.SelectedEvent;
        }
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

        private void EventVersionHtml_Loaded(object sender, RoutedEventArgs e)
        {
            var html = "<html><body>";
            html += App.ViewModel.SelectedEvent.EventVersion;
            html = html + "</body></html>";
            EventVersionHtml.NavigateToString(StringHelper.FixHtml(html));

        }

        private void EventPageBarIconButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(App.ViewModel.SelectedEvent.EventUrl))
            {
                MessageBox.Show("Wydarzenie nie posiada dodatkowej zawartości");
            }
            else
            {
                WebBrowserTask webBroswerTask = new WebBrowserTask();
                webBroswerTask.Uri = new Uri(App.ViewModel.SelectedEvent.EventUrl);
                webBroswerTask.Show();
            }
        }
    }
}